package de.mmbbs;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Bundle;

public class Basic2dObject extends Activity{
	private int width;
	private int height;
	
	private int positionX;
	private int positionY;
	
	private Bitmap image;
	
	public Basic2dObject()
	{
		super();
		width=0;
		height=0;
		positionX=50;
		positionY=100;
		image=null;
	}
	
	public Basic2dObject(int w, int h, Bitmap img)
	{
		width=w;
		height=h;
		image = img;
	}
	
	
	public void paint(Canvas gc)
	{
		gc.drawBitmap(image, positionX, positionY, null);
	}
	
	public boolean hit(Basic2dObject obj)
	{
		if	(	( positionX + width >= obj.getPositionX() )
			&&	( positionX <= obj.getPositionX() + obj.getWidth() )
			&&	( positionY + height >= obj.getPositionY() )
			&&	( positionY <= obj.getPositionY() + obj.getHeight() )
			)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	public int getWidth()
	{
		return width;
	}
	public int getHeight()
	{
		return height;
	}
	
	public int getPositionX()
	{
		return positionX;
	}
	
	public int getPositionY()
	{
		return positionY;
	}
	
	public void setPosition(int x, int y)
	{
		positionX = x;
		positionY = y;
	}

	public void setBitmap(Bitmap bm) {
		image=bm;
		this.width = bm.getWidth();  // Dringend gebraucht
		this.height = bm.getHeight(); //dringend gebraucht
	}

}
